The following functions can be implemented by media packetizer components. Most of these functions must be implemented in your component, but some are optional, as noted in the discussion section of the optional functions.
The RTPMPInitialize function is called to initialize your media packetizer component. RTPMPInitialize will be called after your component is opened, and after the RTPMPPreflightMedia call, but before it is sent any data to packetize.
ComponentResult RTPMPInitialize (
RTPMediaPacketizer rtpm,
SInt32 inFlags);
This function is called to determine whether your packetizer can work with a given media type and sample description. Return noErr if you can packetize this type of data. Return qtsUnsupportedFeatureErr if you cannot.
ComponentResult RTPMPPreflightMedia (
RTPMediaPacketizer rtpm,
OSType inMediaType,
SampleDescriptionHandle inSampleDescription);
This function is called periodically in the application program's event loop to allocate time to your media packetizer. If your packetizer operates synchronously, doing all of its work in the RTPMPSetSampleData function, the RTPMPIdle function does nothing. If your packetizer operates asynchronously, it sets outFlags to kRTPMPStillProcessingData in RTPMPSetSampleData and processes data during RTPMPIdle. Set outFlags to 0 if you have processed all the data passed to you in the last RTPMPSetSampleData . Set outFlags to kRTPMPStillProcessingData if you need the application to call RTPMPIdle again.
ComponentResult RTPMPIdle (
RTPMediaPacketizer rtpm,
SInt32 inFlags,
SInt32 *outFlags);
The packetizer can use this time to process the data in its buffer. Data is placed in the buffer by the RTPMPSetSampleData function. If the data has not all been processed, the RTPMPSetSampleData function sets outFlags to kRTPMPStillProcessingData ; this causes the calling application to call RTPMPIdle. The RTPMPIdle function can also set outFlags to kRTPMPStillProcessingData if it needs more time. The calling application will call RTPMPIdle repeatedly until you set outFlags to 0.
Your packetizer may make calls to the packet builder in response to this call.
This function is called to provide sample data to your media packetizer component. Packetize the data according to your own algorithm and pass it to the selected packet builder. If you can process all the data immediately, set outFlags to 0. If you need more data to complete a packet, set outFlags to kRTPMPWantsMoreDataFlag . If you need more time, set outFlags to kRTPMPStillProcessingData and continue processing in RTPMPIdle.
ComponentResult RTPMPSetSampleData (
RTPMediaPacketizer rtpm,
const RTPMPSampleDataParams *inSampleData,
SInt32 *outFlags);
/* flags for RTPMPSampleDataParams*/
enum {
kRTPMPSyncSampleFlag= 0x00000001
};
struct RTPMPSampleDataParams {
UInt32 version;
UInt32 timeStamp;
UInt32 duration; /* 0 if not specified*/
UInt32 playOffset; /* 0 if not specified*/
Fixed playRate;
SInt32 flags;
UInt32 sampleDescSeed;
Handle sampleDescription;
RTPMPSampleRef sampleRef;
UInt32 dataLength;
const UInt8 * data;
RTPMPDataReleaseUPP releaseProc;
void * refCon;
};
typedef struct RTPMPSampleDataParamsRTPMPSampleDataParams;
This routine is called to pass media data to a media packetizer. Note that the caller owns the RTPMPSampleDataParams struct pointed to by inSampleData . Your media packetizer must copy any fields of the struct that it wants to keep. The caller will maintain only the media data poionted to by the data field in the struct until you call the release proc.
Your media packetizer must call the release proc when done with the media data.
Calling RTPMPSetSampleData adds data cumulatively to any previous calls to RTPMPSetSampleData . The data can contain any number of samples (1 or more), or a partial sample.
Set outFlags to 0 if your packetizer is able to finish packetizing the sample data, or kRTPMPWantsMoreDataFlag if it needs more data to build a packet. Set outFlags to kRTPMPStillProcessingData if you need more time. This will cause a series of calls to RTPMPIdle, which grants time to your packetizer in order to process the data passed in RTPMPSetSampleData .
Your packetizer may make calls to the packet builder in response to this call.
Stop packetizing your current input, set your packetizer's state to idle, and flush your input buffer. Reset your packetizer's state as if it had just been opened and initialized.
ComponentResult RTPMPReset (
RTPMediaPacketizer rtpm,
SInt32 inFlags);
This function is called to set any one of several parameters for a media packetizer.
ComponentResult RTPMPSetInfo (
RTPMediaPacketizer rtpm,
OSType inSelector,
const void *ioParams);
This function is used to get information of various types from your media packetizer. You will need to return information as a data structure of the appropriate type for the requested information.
ComponentResult RTPMPGetInfo (
RTPMediaPacketizer rtpm,
OSType inSelector,
void *ioParams);
/* info selectors - get only */
kRTPMPPayloadTypeInfo ('rtpp'),/* RTPMPPayloadTypeParams* */
kRTPMPRTPTimeScaleInfo ('rtpt'),/* TimeScale* */
kRTPMPRequiredSampleDescriptionInfo ('sdsc'),
/* SampleDescriptionHandle* */
kRTPMPMinPayloadSize ('mins'),
/* UInt32*, doesn't include rtp header; default is 0 */
kRTPMPMinPacketDuration ('mind'),
/* UInt3* in milliseconds; default is no min */
kRTPMPSuggestedRepeatPktCountInfo ('srpc'),/* UInt32* */
kRTPMPSuggestedRepeatPktSpacingInfo ('srps'),
/* UInt32* in milliseconds */
kRTPMPMaxPartialSampleSizeInfo ('mpss'),/* UInt32* in bytes */
kRTPMPPreferredBufferDelayInfo ('prbd') /* UInt32* in milliseconds */
The kRTPMPPayloadTypeInfo selector requires you to fill out an RTPMPPayloadTypeParams structure, which describes the payload being used.
/* flags for RTPMPPayloadTypeParams */
enum {
kRTPMPPayloadTypeStaticFlag= 0x00000001,
kRTPMPPayloadTypeDynamicFlag = 0x00000002
};
struct RTPMPPayloadTypeParams {
UInt32 flags;
UInt32 payloadNumber;
short nameLength; /* in: size of payloadName buffer
(counting null terminator) -- this will be reset to needed length and paramErr returned if too
small */
char * payloadName; /* caller must provide buffer */
};
typedef struct RTPMPPayloadTypeParams RTPMPPayloadTypeParams;
If the flags field of the structure is kRTPMPPayloadTypeStaticFlag , then the payloadNumber field contains the RTP payload number; if the flags field of the structure is kRTPMPPayloadTypeDynamicFlag , then the payloadName field contains the name of the dynamic payload encoding being used. The caller must allocate this payloadName field. You need to copy the payload type string to the buffer pointed to by payloadName (a null-terminated string). When RTPMPGetInfo is called, RTPMPPayloadTypeParams.nameLength will be the available size of the input buffer (specified by payloadName ). If this size is too small for the payload identifier, set nameLength to the size of the buffer you need (including the null terminator) and return paramErr . This will cause QuickTime to reallocate the buffer and call your packetizer again.
Sets the time scale your media packetizer will use. The time scale is the number of time units that pass in one second (when the media is playing at a rate of 1). The timescale must be set before any calls are made to RTPMPSetSampleData .
ComponentResult RTPMPSetTimeScale (
RTPMediaPacketizer rtpm,
TimeScale inTimeScale);
Return a pointer to the timescale in use by your media packetizer. The timescale indicates the number of time units that pass in one second (when the media is playing at a rate of 1).
ComponentResult RTPMPGetTimeScale (
RTPMediaPacketizer rtpm,
TimeScale *outTimeScale);
This call may be made during set up for a live transmission. It tells your packetizer what time base is in use by the calling application.
ComponentResult RTPMPSetTimeBase (
RTPMediaPacketizer rtpm,
TimeBase inTimeBase);
Return the time base passed to you in RTPMPSetTimeBase.
ComponentResult RTPMPGetTimeBase (
RTPMediaPacketizer rtpm,
TimeBase *outTimeBase);
This call is made to determine whether your media packetizer has a particular characteristic, such as whether it supports a user settings dialog.
ComponentResult RTPMPHasCharacteristic (
RTPMediaPacketizer rtpm,
OSType inSelector,
Boolean *outHasIt);
Selects which packet builder your media packetizer will use. A media packetizer always sends its output to a packet builder. The specified packet builder may assemble actual RTP packets, or it may use information about the packet to build a hint track.
ComponentResult RTPMPSetPacketBuilder (
RTPMediaPacketizer rtpm,
ComponentInstance inPacketBuilder);
Return the component instance of the packet builder component being used by your media packetizer.
ComponentResult RTPMPGetPacketBuilder (
RTPMediaPacketizer rtpm,
ComponentInstance *outPacketBuilder);
Sets the type of media that your media packetizer will process (for example, VideoMediaType or SoundMediaType ). The media type will be set prior to any calls to RTPMPSetSampleData . It will not change after such calls.
ComponentResult RTPMPSetMediaType (
RTPMediaPacketizer rtpm,
OSType inMediaType);
Return the media type passed in by RTPMPSetMediaType (such as VideoMediaType or SoundMediaType ).
ComponentResult RTPMPGetMediaType (
RTPMediaPacketizer rtpm,
OSType *outMediaType);
Sets the maximum packet size, in bytes, for packets created by your media packetizer.
ComponentResult RTPMPSetMaxPacketSize (
RTPMediaPacketizer rtpm,
UInt32 inMaxPacketSize);
The media packetizer must not create packets larger than this value. The limit applies only to the payload data. The maximum packet size will not change during a presentation. Streaming will be most efficient if this value is set to the largest packet size that can traverse the network without being split.
RTPMPSetMaxPacketSize will not be called after calling RTPMPSetSampleData . If RTPMPSetMaxPacketSize is not called, use a default value.
Return the maximum packet size, in bytes, that your packetizer is set to create.
ComponentResult RTPMPGetMaxPacketSize (
RTPMediaPacketizer rtpm,
UInt32 *outMaxPacketSize);
Sets the maximum packet duration, in milliseconds, that the media packetizer is to use.
ComponentResult RTPMPSetMaxPacketDuration (
RTPMediaPacketizer rtpm,
UInt32 inMaxPacketDuration);
Return the maximum packet duration, in milliseconds, currently set for this packetizer.
ComponentResult RTPMPGetMaxPacketDuration (
RTPMediaPacketizer rtpm,
UInt32 *outMaxPacketDuration);
Obtain media-specific settings from the user through a dialog box.
ComponentResult RTPMPDoUserDialog (
RTPMediaPacketizer rtpm,
ModalFilterUPP inFilterUPP,
Boolean *canceled);
If a media packetizer supports a user dialog (see RTPMPHasCharacteristic ), it can put up a dialog allowing the user to enter media-specific settings. The settings can be requested by the calling application by calling RTPMPGetSettingsIntoAtomContainerAtAtom, and can be restored or set directly from an application by calling RTPMPSetSettingsFromAtomContainerAtAtom.
Sets the media-specific settings of a media packetizer. The data is passed in an atom inside an AtomContainer.
ComponentResult RTPMPSetSettingsFromAtomContainerAtAtom (
RTPMediaPacketizer rtpm,
QTAtomContainer inContainer,
QTAtom inParentAtom);
This function should only be called if your media packetizer supports packetizer-specific settings. To determine if a media packetizer supports this function, the application will call RTPMPHasCharacteristic .
You can be asked to return the the packetizer-specific settings through the call RTPMPGetSettingsIntoAtomContainerAtAtom. You can be asked to bring up a dialog which allows the user to change the settings through the RTPMPDoUserDialog call.
Return the media-specific setting of a media packetizer. The caller must allocate a QT AtomContainer to hold the returned settings.
ComponentResult RTPMPGetSettingsIntoAtomContainerAtAtom (
RTPMediaPacketizer rtpm,
QTAtomContainer inOutContainer,
QTAtom inParentAtom);
This function should only be called if the media packetizer supports packetizer-specific settings. To determine if your media packetizer supports this function, the application will call RTPMPHasCharacteristic .
The packetizer-specific settings can be set by through the RTPMPSetSettingsFromAtomContainerAtAtom call. You may be asked to bring up a dialog which allows the user to change the settings through the RTPMPDoUserDialog call.
Return the media-specific settings of a media packetizer as text in a format presentable to the user.
ComponentResult RTPMPGetSettingsAsText (
RTPMediaPacketizer rtpm,
Handle *text);
This function should only be called if the media packetizer supports packetizer-specific settings. To determine if your media packetizer supports this function, the application will call RTPMPHasCharacteristic .
The packetizer-specific settings can be set by the RTPMPSetSettingsFromAtomContainerAtAtom call. You may be asked to bring up a dialog which allows the user to change the settings through the RTPMPDoUserDialog call.
The RTPMPGetSettingsAsText function expects you to return your user settings as text.
| Previous | Chapter Contents | Chapter Top | Next |